<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
 
jimport('joomla.application.component.view');
 
class CouponsViewCoupon extends JView
{
        protected $form;
	protected $item;
        protected $isNew;
        
	// Overwriting JView display method
	function display($tpl = null) 
	{       
            JRequest::setVar('hidemainmenu', true);
            $this->form	= $this->get('Form');
            $this->item	= $this->get('Item');
            $this->isNew = $this->item->id == null ;
            
            JToolBarHelper::title( JText::_('COM_COUPONS_COUPONS').': '.( $this->isNew ? JText::_('COM_COUPONS_NEW') : JText::_('COM_COUPONS_EDIT') ) );
            JToolBarHelper::apply('coupon.apply');
            JToolBarHelper::save('coupon.save');
            
            if ($this->isNew)  
                JToolBarHelper::cancel('coupon.cancel');
            else 
            {
                JToolBarHelper::cancel( 'coupon.cancel', 'COM_COUPONS_CLOSE' );
                //Nesessary to be set when EDIT! 
                if($this->item->id > 0 )
                    JFactory::getApplication()->setUserState(JRequest::getCmd('option').'.edit.coupon', $this->item);
            }
            
            // Check for errors.
            if (count($errors = $this->get('Errors'))) 
            {
                    JError::raiseError(500, implode('<br />', $errors));
                    return false;
            }

            parent::display($tpl);
	}
        
       
}
?>